<?php

class DataController extends Controller{

    private $M_data;
	
    /**
     * 构造方法
     * 初始化
     */
    public function __construct(){
        $this->M_data = Model::getInstance('datas');
    }
	
    //模块首页
    public function index(){
        global $controller;

        $list = $this->M_data->getAllTableName();

		$total = 0;
        foreach ($list as $k => $v) {
            $list[$k]['size'] = byteFormat($v['data_length'] + $v['index_length']);
            $total+=$v['data_length'] + $v['index_length'];
        }

        $data = array(
            'controller'=>$controller,
            'list'=>$list,
			'tables'=>count($list),
			'total'=>byteFormat($total)
        );

        Template::show('data/index.php',$data);
    }

    public function run(){
        global $controller;
		
        $data = array(
            'controller'=>$controller
        );

        Template::show('data/run.php',$data);
    }

    public function runSql(){
        echo Response::Default_JSON(0,array(1=>1));
    }
}